<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            width: 120px;
            height: 35px;
        }
    </style>
</head>

<body>
    <button>开光灯</button>
    <script>
        var btn = document.querySelector('button')
        var body = document.body
        var flag = true
        btn.onclick = function() {
            if (flag) {
                body.style.backgroundColor = 'black'
                flag = false
            } else {
                body.style.backgroundColor = '#fff'
                flag = true
            }


        }
    </script>
</body>

</html>